package com.xiao.rabbitmq.controller;

import com.xiao.rabbitmq.rabbit.IMessageQueueService;
import com.xiao.rabbitmq.rabbit.MQConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/Test")
public class TestController {

    @Autowired
    private IMessageQueueService messageQueueService;

    @ResponseBody
    @RequestMapping("/sendMessage")
    public String sendMessage() {
        System.out.println("hello");
//        messageQueueService.send(MQConstant.HELLO_QUEUE_NAME,"测试延迟发送消息1111",3000);
        messageQueueService.send(MQConstant.HELLO_QUEUE_NAME,"测试发送正常消息");
        return "Hello";
    }

    @ResponseBody
    @RequestMapping("/sendDelayMessage")
    public String sendDelayMessage() {
        System.out.println("hello2222");
//        messageQueueService.send(MQConstant.HELLO_QUEUE_NAME,"测试延迟发送消息1111",3000);
        messageQueueService.send(MQConstant.HELLO_QUEUE_NAME,"测试发送延迟消息", 5000);
        return "Hello";
    }

}
